<template>

	<el-main style="padding:0 20px;">
		<el-descriptions :column="1" border size="small">
			<el-descriptions-item label="请求方法">{{data.method_type}}</el-descriptions-item>
			<el-descriptions-item label="请求接口">{{data.route}}</el-descriptions-item>
			<el-descriptions-item label="状态代码">{{data.return_code}}</el-descriptions-item>
			<el-descriptions-item label="日志时间">{{$TOOL.dateFormat(data.in_at)}}</el-descriptions-item>
		</el-descriptions>
		<el-collapse v-model="activeNames" style="margin-top: 20px;">
			<el-collapse-item title="入参" name="1">
				<json-viewer :value="inJsonData"></json-viewer>
			</el-collapse-item>
			<el-collapse-item title="返回参数" name="2">
				<json-viewer :value="outJsonData"></json-viewer>
			</el-collapse-item>
		</el-collapse>
	</el-main>
</template>

<script>
	import JsonViewer from 'vue-json-viewer'
	export default {
		components: {
			JsonViewer: JsonViewer
		},
		data() {
			return {
				data: {},
				inJsonData: {},
				outJsonData: {},
				activeNames: ['1','2'],
				typeMap: {
					'info': "info",
					'warn': "warning",
					'error': "error"
				}
			}
		},
		methods: {
			setData(data){
				this.data = data
				if (data.param_data) {
					this.inJsonData = JSON.parse(data.param_data)
				}
				if (data.return_data) {
					this.outJsonData = JSON.parse(data.return_data)
				}
			}
		}
	}
</script>

<style scoped>
	.code {background: #848484;padding:15px;color: #fff;font-size: 12px;border-radius: 4px;}
</style>
